--IF EXISTS(SELECT name FROM sys.databases
 --    WHERE name = 'Contacts')
 --    DROP DATABASE Contacts;

--CREATE DATABASE Contacts;


IF (OBJECT_ID('PlaceResidence')IS NOT NULL)
DROP TABLE PlaceResidence;

CREATE TABLE Contacts..PlaceResidence
(PlaceResidenceID int not null primary key,
PlaceResidenceCity varchar(60),
PlaceResidenceStreet varchar(60),
PlaceResidenceHome varchar(20),
PlaceResidenceFlat varchar(20))


IF (OBJECT_ID('Subdivision')IS NOT NULL)
DROP TABLE Subdivision;

CREATE TABLE Contacts..Subdivision
(SubdivisionID int not null primary key,
SubdivisionName varchar(60))

IF (OBJECT_ID('Position')IS NOT NULL)
DROP TABLE Position;

CREATE TABLE Contacts..Position
(PositionID int not null primary key,
PositionName varchar(60) not null,
SubdivisionID int)

IF (OBJECT_ID('Personality')IS NOT NULL)
DROP TABLE Personality;

CREATE TABLE Contacts..Personality
(PersonalityID int not null primary key,
PersonalityLastName varchar(60) not null,
PersonalityFirstName varchar(30) not null,
PersonalityPatronymic varchar(60) not null,
PersonalitySex varchar(10) not null,
PersonalityMobilePhone varchar(20),
PersonalityInternalPhone varchar(20),
PersonalityEMAIL varchar(30),
PersonalityPhoto text,
PersonalityAdditionalInformation varchar(255),
PlaceResidenceID int,
PositionID int)



